package com.songlanyun.modules.supplychainmessage.enums;

import com.fasterxml.jackson.annotation.JsonCreator;

import cn.hutool.core.util.ObjectUtil;

/**
 * 消息回调类型
 *
 * @author lijiahe 2023-02-27
 */

public enum MessageCallbackType {

    /**
     * 交易成功
     */
    ORDER_SUCCESS("order.success", "交易成功"),
    /**
     * 商品上架
     */
    GOODS_ON_SALE("goods.on.sale", "商品上架"),
    /**
     * 商品下架
     */
    GOODS_UNDERCARRIAGE("goods.undercarriage", "商品下架"),
    /**
     * 商品已收货
     */
    ORDER_DELIVERED("order.delivered", "商品已收货"),
    /**
     * 商品修改
     */
    GOODS_ALTER("goods.alter", "商品修改"),
    /**
     * 商品价格变更
     */
    GOODS_PRICE_ALTER("goods.price.alter", "商品价格变更"),
    /**
     * 商家已发货
     */
    ORDER_DELIVERY("order.delivery", "商家已发货"),
    /**
     * 售后退款到账
     */
    AFTER_SALE_SUCCESS("afterSale.success", "售后退款到账"),
    /**
     * 售后同意
     */
    AFTER_SALE_AGREE("afterSale.agree", "售后同意"),
    /**
     * 售后拒绝
     */
    AFTER_SALE_REFUSE("afterSale.refuse", "售后拒绝"),
    /**
     * 商品库添加
     */
    GOODS_STORAGE_ADD("goods.storage.add", "商品库添加"),
    /**
     * 移除商品库商品
     */
    GOODS_STORAGE_REMOVE("goods.storage.remove", "移除商品库商品"),

    ;

    private String code;
    private String desc;

    MessageCallbackType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    @JsonCreator
    public static MessageCallbackType getByCode(String code) {
        for (MessageCallbackType type : MessageCallbackType.values()) {
            if (ObjectUtil.equal(code, type.code())) {
                return type;
            }
        }
        return null;
    }
}
